package com.qishao.oss_service.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;

@Component
public class OssConstantPropertiesUtils implements InitializingBean {


    public static String ACCESSKEY;  //aliyun的accesskey
    public static String ACCESSKEYSECRET;   //aliyun的秘钥
    public static String BUKETNAME;   //阿里云中自己的oss中的buket的名称
    public static String ENDPOINT;   //外网访问地址


    // aliyun accessKeyId
    @Value("${aliyun.oss.file.accesskey}")
    private String accessKey;

    //ailiyun accessKey的秘钥
    @Value("${aliyun.oss.file.accesskeysecret}")
    private String accessKeySecret;

    //buketNmae
    @Value("${aliyun.oss.file.buketname}")
    private String buKetName;

    //buket外网访问地址
    @Value("${aliyun.oss.file.endpoint}")
    private String endpoint;

    {

        ACCESSKEY = accessKey;
        ACCESSKEYSECRET = accessKeySecret;
        BUKETNAME = buKetName;
        ENDPOINT = endpoint;

    }

    @Override
    public void afterPropertiesSet() throws Exception {
        ACCESSKEY = accessKey;
        ACCESSKEYSECRET = accessKeySecret;
        BUKETNAME = buKetName;
        ENDPOINT = endpoint;
    }
}
